<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>月计划执行-目的地运营集团数据管理平台</title>
<include file="Include:style" />
<style>
	.progress{ margin-bottom: 0; }
	.progress{ width: 100px; height: 24px; margin-top: 3px; background: #eee; box-shadow: none; }
	.progress-bar{ box-shadow: none; }
	.color1 .progress-bar-warning{ background: #ffd5a1; }
	.color2 .progress-bar-warning{ background: #cbc9f5; }
	.color3 .progress-bar-warning{ background: #ffb7c5; }
	.color4 .progress-bar-warning{ background: #b1e4ae; }
	.color5 .progress-bar-warning{ background: #b9d8ff; }
</style>
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text"><if condition="$project['info_id'] neq NULL">商务跟进</if>项目 > [{$project['project_num']}]{$project['project_name']} > 月计划执行</div>
	</div>
	<div id="content">
		<if condition="$mid eq ''">
		<include file="Include:project_header" />
		</if>
		<div>
			<div class="form-main">
				<div class="form-title" style="padding-top: 5px">
					<select name="year" class="w100">
						<foreach name="year_list" item="vo">
							<option value="{$vo}" <if condition="$vo eq $year">selected</if>>{$vo}年</option>
						</foreach>
					</select>
				</div>
				<div class="form-table-item">
					<form class="in_form" action="__APP__/Project/project_income_month" method="post" enctype="multipart/form-data">
						<input type="hidden" name="action" value="add">
						<input type="hidden" name="pid" value="{$project['id']}">
						<input type="hidden" name="year" value="{$year}">
						<table class="table">
							<tbody>
								<tr class="form-table-header">
									<td>计划指标</td>
									<td>年度目标</td>
									<for start="1" end="12" comparison="elt" step="1">
									<td>{$i}月</td>
									</for>
								</tr>
								<foreach name="result_jh" item="vo">
								<tr class='gz_tr'>
									<if condition="((((get_permission($qs,NULL,3)) and ($project['add_uid'] eq $login_id)) or (get_permission($qs,NULL,2) and (in_array($project['center_id'],$manage_id))) or (get_permission($qs,NULL,1))) or ($project['director_uid'] eq $login_id) or ($project['manager_uid'] eq $login_id)) and ($project['status'] eq 1)">
										<td>{$vo['name2']}<input type="hidden" name="tid[]" value="{$vo['name1']}"></td>
										<td><input type="text" name="m{$vo['name1']}y_sum" value="{$vo['y_sum']}" class="form-control required-text all w100" autocomplete="off"></td>
										<td><input type="text" name="m{$vo['name1']}m1" value="{$vo['m1']}" class="form-control required-text add w100" autocomplete="off"></td>
										<td><input type="text" name="m{$vo['name1']}m2" value="{$vo['m2']}" class="form-control required-text add w100" autocomplete="off"></td>
										<td><input type="text" name="m{$vo['name1']}m3" value="{$vo['m3']}" class="form-control required-text add w100" autocomplete="off"></td>
										<td><input type="text" name="m{$vo['name1']}m4" value="{$vo['m4']}" class="form-control required-text add w100" autocomplete="off"></td>
										<td><input type="text" name="m{$vo['name1']}m5" value="{$vo['m5']}" class="form-control required-text add w100" autocomplete="off"></td>
										<td><input type="text" name="m{$vo['name1']}m6" value="{$vo['m6']}" class="form-control required-text add w100" autocomplete="off"></td>
										<td><input type="text" name="m{$vo['name1']}m7" value="{$vo['m7']}" class="form-control required-text add w100" autocomplete="off"></td>
										<td><input type="text" name="m{$vo['name1']}m8" value="{$vo['m8']}" class="form-control required-text add w100" autocomplete="off"></td>
										<td><input type="text" name="m{$vo['name1']}m9" value="{$vo['m9']}" class="form-control required-text add w100" autocomplete="off"></td>
										<td><input type="text" name="m{$vo['name1']}m10" value="{$vo['m10']}" class="form-control required-text add w100" autocomplete="off"></td>
										<td><input type="text" name="m{$vo['name1']}m11" value="{$vo['m11']}" class="form-control required-text add w100" autocomplete="off"></td>
										<td><input type="text" name="m{$vo['name1']}m12" value="{$vo['m12']}" class="form-control required-text add w100" autocomplete="off"></td>
									<else/>
										<td>{$vo['name2']}</td>
										<td>{$vo['y_sum']}</td>
										<td>{$vo['m1']}</td>
										<td>{$vo['m2']}</td>
										<td>{$vo['m3']}</td>
										<td>{$vo['m4']}</td>
										<td>{$vo['m5']}</td>
										<td>{$vo['m6']}</td>
										<td>{$vo['m7']}</td>
										<td>{$vo['m8']}</td>
										<td>{$vo['m9']}</td>
										<td>{$vo['m10']}</td>
										<td>{$vo['m11']}</td>
										<td>{$vo['m12']}</td>
									</if>
								</tr>
								</foreach>
							</tbody>
						</table>
					</form>
					
					<div class="form-btn-item">
						<if condition="((((get_permission($qs,NULL,3)) and ($project['add_uid'] eq $login_id)) or (get_permission($qs,NULL,2) and (in_array($project['center_id'],$manage_id))) or (get_permission($qs,NULL,1))) or ($project['director_uid'] eq $login_id) or ($project['manager_uid'] eq $login_id)) and ($project['status'] eq 1)">
							<p class="Text_c red mb10 hide">月度总和不能大于年度目标</p>
							<button class="btn btn-submit" type="button">提交</button>
						</if>
					</div>
					<table class="table">
						<tbody>
							<tr class="form-table-header">
								<td>执行完成情况</td>
								<td>完成总量</td>
								<for start="1" end="12" comparison="elt" step="1">
								<td>{$i}月</td>
								</for>
							</tr>
							<foreach name="result_jh" item="vo">
							<tr class='bl_tr color{$key+1}'>
								<td class="middle">{$vo['name2']}</td>
								<td>
									<div class="progress" data-toggle="tooltip" data-placement="top" data-original-title="总量：{$vo['n_sum']} 比率：{$vo['n_sum_bl']}%">
										<div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="{$vo['n_sum_bl']}" aria-valuemin="0" aria-valuemax="100" style="width:{$vo['n_sum_bl']}%"></div>
									</div>
								</td>
								<td>
									<div class="progress" data-toggle="tooltip" data-placement="top" data-original-title="总量：{$vo['n1']} 比率：{$vo['n1_bl']}%">
										<div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="{$vo['n1_bl']}" aria-valuemin="0" aria-valuemax="100" style="width: {$vo['n1_bl']}%"></div>
									</div>
								</td>
								<td>
									<div class="progress" data-toggle="tooltip" data-placement="top" data-original-title="总量：{$vo['n2']} 比率：{$vo['n2_bl']}%">
										<div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="{$vo['n2_bl']}" aria-valuemin="0" aria-valuemax="100" style="width: {$vo['n2_bl']}%"></div>
									</div>
								</td>
								<td>
									<div class="progress" data-toggle="tooltip" data-placement="top" data-original-title="总量：{$vo['n3']} 比率：{$vo['n3_bl']}%">
										<div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="{$vo['n3_bl']}" aria-valuemin="0" aria-valuemax="100" style="width: {$vo['n3_bl']}%"></div>
									</div>
								</td>
								<td>
									<div class="progress" data-toggle="tooltip" data-placement="top" data-original-title="总量：{$vo['n4']} 比率：{$vo['n4_bl']}%">
										<div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="{$vo['n4_bl']}" aria-valuemin="0" aria-valuemax="100" style="width: {$vo['n4_bl']}%"></div>
									</div>
								</td>
								<td>
									<div class="progress" data-toggle="tooltip" data-placement="top" data-original-title="总量：{$vo['n5']} 比率：{$vo['n5_bl']}%">
										<div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="{$vo['n5_bl']}" aria-valuemin="0" aria-valuemax="100" style="width: {$vo['n5_bl']}%"></div>
									</div>
								</td>
								<td>
									<div class="progress" data-toggle="tooltip" data-placement="top" data-original-title="总量：{$vo['n6']} 比率：{$vo['n6_bl']}%">
										<div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="{$vo['n6_bl']}" aria-valuemin="0" aria-valuemax="100" style="width: {$vo['n6_bl']}%"></div>
									</div>
								</td>
								<td>
									<div class="progress" data-toggle="tooltip" data-placement="top" data-original-title="总量：{$vo['n7']} 比率：{$vo['n7_bl']}%">
										<div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="{$vo['n7_bl']}" aria-valuemin="0" aria-valuemax="100" style="width: {$vo['n7_bl']}%"></div>
									</div>
								</td>
								<td>
									<div class="progress" data-toggle="tooltip" data-placement="top" data-original-title="总量：{$vo['n8']} 比率：{$vo['n8_bl']}%">
										<div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="{$vo['n8_bl']}" aria-valuemin="0" aria-valuemax="100" style="width: {$vo['n8_bl']}%"></div>
									</div>
								</td>
								<td>
									<div class="progress" data-toggle="tooltip" data-placement="top" data-original-title="总量：{$vo['n9']} 比率：{$vo['n9_bl']}%">
										<div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="{$vo['n9_bl']}" aria-valuemin="0" aria-valuemax="100" style="width: {$vo['n9_bl']}%"></div>
									</div>
								</td>
								<td>
									<div class="progress" data-toggle="tooltip" data-placement="top" data-original-title="总量：{$vo['n10']} 比率：{$vo['n10_bl']}%">
										<div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="{$vo['n10_bl']}" aria-valuemin="0" aria-valuemax="100" style="width: {$vo['n10_bl']}%"></div>
									</div>
								</td>
								<td>
									<div class="progress" data-toggle="tooltip" data-placement="top" data-original-title="总量：{$vo['n11']} 比率：{$vo['n11_bl']}%">
										<div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="{$vo['n11_bl']}" aria-valuemin="0" aria-valuemax="100" style="width: {$vo['n11_bl']}%"></div>
									</div>
								</td>
								<td>
									<div class="progress" data-toggle="tooltip" data-placement="top" data-original-title="总量：{$vo['n12']} 比率：{$vo['n12_bl']}%">
										<div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="{$vo['n12_bl']}" aria-valuemin="0" aria-valuemax="100" style="width: {$vo['n12_bl']}%"></div>
									</div>
								</td>
							</tr>
							</foreach>
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
</div>
<include file="Include:javascript" />
<script type="text/javascript">
$(function(){
	$(document).on("change","[name='year']",function(){
		var val = $(this).val();
		window.location.href="__APP__/Project/project_income_month/id/{$project['id']}/year/"+val;
	});
	
	$('.btn-submit').on("click",function(){
		var tag = true;
		$('.required-text').each(function(){
			var _this = $(this),
				val = _this.val();
			if(val!="" && ! /^\d+(?:\.\d{1,2})?$/.test(val)){
				$(this).addClass('red_border');
				tag = false;
			}
		});
		for(var i = 0; i < $('.gz_tr').length; i++){
			var p = 0;
			$('.gz_tr').eq(i).find('.add').each(function(){
				var val = $(this).val() ? $(this).val() : 0
				p += parseFloat(val);
			})
			if(parseFloat($('.gz_tr').eq(i).find('.all').val())<p){
				tag = false;
				$('p.red').show();
			}
		}
		if(tag){
			$.ajax({
				cache:true,
				type:"POST",
				dataType:"json",
				url:"__APP__/Project/project_income_month",
				data:$('.in_form').serialize(),
				success:function(data){
					success_pop(data['status'],data['msg']);
				}
			});
		}

		$('.required-text').focus(function(){
			$(this).removeClass('red_border');
			$('p.red').hide();
		})
	});
	
});
</script>
</body>
</html>